<template>
  <div>
    <button @click="startWorker">Start Worker</button>
    <p v-if="loading">Loading...</p>
    <p v-else>{{ result }}</p>
  </div>
</template>
<script>
export default {
  data() {
    return {
      loading: false,
      result: ''
    };
  },
  methods: {
    startWorker() {
      this.loading = true;
      const worker = new Worker('./worker.js');
      worker.onmessage = function (e) {
        this.result = e.data;
        this.loading = false;
      };
    }
  }
};
</script>
